package com.zrgj.config;

import com.zrgj.util.DBUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.SQLException;

@Configuration
public class BeanConfig {

    @Value("${spring.datasource.driver-class-name}")
    private  String driver;
    @Value("${spring.datasource.url}")
    private  String url;
    @Value("${spring.datasource.password}")
    private  String password;
    @Value("${spring.datasource.username}")
    private  String username;





    @Bean("imdb")
    public DBUtil getDBUtil() throws SQLException, ClassNotFoundException {
        DBUtil dbUtil=new DBUtil(driver
            ,url
            ,username
            ,password);

        dbUtil.connect();
        return dbUtil;
    }

    @Bean("ali")
    public DBUtil getDBUtil2() throws SQLException, ClassNotFoundException {
        DBUtil dbUtil=new DBUtil(driver
                ,url
                ,username
                ,password);

        dbUtil.connect();
        return dbUtil;
    }
}
